package com.kaibo.roomdemo.data.db.dao

import android.arch.persistence.room.Dao
import android.arch.persistence.room.Insert
import android.arch.persistence.room.OnConflictStrategy
import android.arch.persistence.room.Query
import com.kaibo.roomdemo.data.db.entity.UserEntity
import io.reactivex.Flowable
import io.reactivex.Observable

/**
 * @author Administrator
 * @date 2018/2/7 0007 上午 9:39
 * GitHub：
 * email：
 * description：
 */

@Dao
interface UserDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertUser(user: UserEntity): Long

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertUsers(vararg user: UserEntity): List<Long>

    @Query("SELECT * FROM users WHERE id = :id")
    fun findUserById(id: Long): Flowable<UserEntity>

    @Query("SELECT * FROM users")
    fun findUserAll(): Flowable<List<UserEntity>>


}